/**
 * 
 */
package nl.sportan.samenloop.communication;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * @author Bram Wiekens
 *
 */
public class Utils {

	public static String retrieveData(String url) {
		StringBuilder builder = new StringBuilder();
		HttpURLConnection urlConnection = null;
	
		try {
			URL urlObj = new URL(url);
			urlConnection = (HttpURLConnection) urlObj.openConnection();

			InputStream in = new BufferedInputStream(
					urlConnection.getInputStream());
			BufferedReader reader = new BufferedReader(new InputStreamReader(in));
			
			String line;
			while ((line = reader.readLine()) != null) {
				builder.append(line);
			}
			
		} catch (Exception e) {

		} finally {
			if (urlConnection != null) {
				urlConnection.disconnect();
			}
		}

		return builder.toString();
	}
	
}
